package com.musicdaze.utils;

/**
 * util for passing a pair of two different instances of distinct classes
 * @author mfujihara
 * 
 * @param <S>
 * @param <T>
 */
public class Pair<S, T> {

  /** param left */
  public S left;
  /** param right */
  public T right;

  /**
   * public constructor setting left and right to null
   */
  public Pair() {
    this.left = null;
    this.right = null;
  }

  /**
   * public constructor to set left and right for this pair
   * @param left the value to set left as
   * @param right the value to set right as
   */
  public Pair(S left, T right) {
    this.left = left;
    this.right = right;
  }

  /**
   * checks for equality
   * @param o object to check equality to
   * @return true iff this is equal o based on left and right; false otherwise
   */
  public boolean equals(Object o) {
    if (o instanceof Pair) {
      Pair<S, T> p = (Pair) o;
      return this.left.equals(p.left) && this.right.equals(p.right);
    }
    return false;
  }

  /**
   * gets the hashcode based on left and right
   * @return hashcode
   */
  @Override
  public int hashCode() {
    return this.left.hashCode() + this.right.hashCode();
  }
}
